#pragma once
#include "../../externals/PixelToaster.h"
#include "../basics/basics.h"
#include "primitives.h"
#include "vector.h"
#include "matrix.h"
#include <math.h>

// -- for pi
const float kPi = std::atan(1.0f)*4.0f;

// ================================================================================================
// Find the dot product of two vectors
// ================================================================================================
float DotProduct(const Vector4& v1, const Vector4& v2);

float DotProduct(const Vector4& v1, float x, float y, float z);

// ================================================================================================
// Find the cross product of two vectors
// ================================================================================================
Vector4 CrossProduct(const Vector4& vec1, const Vector4& vec2);

// ================================================================================================
// Compute the magnitude of the vector
// ================================================================================================
inline float Magnitude(const Vector4& vec) {
    return sqrt(DotProduct(vec, vec));
}

inline float Magnitude(float x, float y, float z) {
    return sqrt(x*x + y*y + z*z);
}

// ================================================================================================
// Normalize the vector
// ================================================================================================
inline Vector4 Normalize(const Vector4& vec) {
    float mag = 1/Magnitude(vec);
    Vector4 temp = vec * mag;

    return temp;
}

// ================================================================================================
// Normalize the vector overload 3 floats
// ================================================================================================
inline Vector4 Normalize(float x, float y, float z) {
    float mag = 1/Magnitude(x, y, z);
    return Vector4(x, y, z) * mag;
}

// ================================================================================================
// Rotation functions
// ================================================================================================
void RotateX(float radians, Matrix4x4& mat);
void RotateY(float radians, Matrix4x4& mat);
void RotateZ(float radians, Matrix4x4& mat);

// ================================================================================================
// Rotate about an arbitrary axis
// $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
// Still needs work
// ================================================================================================
void RotateArb(const Vector4& vec, float radians, Matrix4x4& mat);